package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.XxSectionPlan;
import com.ruoyi.system.service.IXxSectionPlanService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水泥目标产值Controller
 * 
 * @author ruoyi
 * @date 2022-03-20
 */
@Controller
@RequestMapping("/system/plan")
public class XxSectionPlanController extends BaseController
{
    private String prefix = "system/plan";

    @Autowired
    private IXxSectionPlanService xxSectionPlanService;

    @RequiresPermissions("system:plan:view")
    @GetMapping()
    public String plan()
    {
        return prefix + "/plan";
    }

    /**
     * 查询水泥目标产值列表
     */
    @RequiresPermissions("system:plan:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(XxSectionPlan xxSectionPlan)
    {
        startPage();
        List<XxSectionPlan> list = xxSectionPlanService.selectXxSectionPlanList(xxSectionPlan);
        return getDataTable(list);
    }

    /**
     * 导出水泥目标产值列表
     */
    @RequiresPermissions("system:plan:export")
    @Log(title = "水泥目标产值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(XxSectionPlan xxSectionPlan)
    {
        List<XxSectionPlan> list = xxSectionPlanService.selectXxSectionPlanList(xxSectionPlan);
        ExcelUtil<XxSectionPlan> util = new ExcelUtil<XxSectionPlan>(XxSectionPlan.class);
        return util.exportExcel(list, "水泥目标产值数据");
    }

    /**
     * 新增水泥目标产值
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存水泥目标产值
     */
    @RequiresPermissions("system:plan:add")
    @Log(title = "水泥目标产值", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(XxSectionPlan xxSectionPlan)
    {
        return toAjax(xxSectionPlanService.insertXxSectionPlan(xxSectionPlan));
    }

    /**
     * 修改水泥目标产值
     */
    @RequiresPermissions("system:plan:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        XxSectionPlan xxSectionPlan = xxSectionPlanService.selectXxSectionPlanById(id);
        mmap.put("xxSectionPlan", xxSectionPlan);
        return prefix + "/edit";
    }

    /**
     * 修改保存水泥目标产值
     */
    @RequiresPermissions("system:plan:edit")
    @Log(title = "水泥目标产值", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(XxSectionPlan xxSectionPlan)
    {
        return toAjax(xxSectionPlanService.updateXxSectionPlan(xxSectionPlan));
    }

    /**
     * 删除水泥目标产值
     */
    @RequiresPermissions("system:plan:remove")
    @Log(title = "水泥目标产值", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(xxSectionPlanService.deleteXxSectionPlanByIds(ids));
    }
}
